#region Usings

using System.Linq;
using KanbanBoard.Client.ViewModel.TaskBoardUseCase;
using KanbanBoard.Tests.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace KanbanBoard.Tests.Client.ViewModel.TaskBoardUseCase {
    [TestClass]
    public class TaskBoardTestBase {
        private TaskBoardViewModel viewModel;
        public ContextFake Context { get; private set; }
        protected string TaskBoard { private get; set; }

        [TestInitialize]
        public void TaskBoardTestBaseInitialize() {
            Context = new ContextFake();
        }

        protected void AssertTaskBoardLooksLike(string expected) {
            var expectedBoard = TaskBoardParser.Parse(expected);

            CollectionAssert.AreEqual(expectedBoard.Keys, viewModel.Columns.Select(_ => _.Name).ToList(),
                                      "Columns do not match");

            foreach (var column in viewModel.Columns) {
                CollectionAssert.AreEqual(expectedBoard[column.Name], column.Tasks.Select(_ => _.Description).ToList(),
                                          "Tasks in {0} column do not match", column.Name);
            }
        }

        protected TaskBoardViewModel StartUseCase() {
            viewModel = new TaskBoardViewModel(Context);
            return viewModel;
        }
    }
}